package com.ruoyi.hotel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.hotel.domain.Room;
import com.ruoyi.hotel.domain.converter.PageConverter;
import com.ruoyi.hotel.domain.converter.RoomConverter;
import com.ruoyi.hotel.domain.from.RoomFrom;
import com.ruoyi.hotel.domain.query.RoomQuery;
import com.ruoyi.hotel.domain.vo.RoomVo;
import com.ruoyi.hotel.mapper.HomeStayMapper;
import com.ruoyi.hotel.mapper.RoomMapper;
import com.ruoyi.hotel.service.RoomService;

import com.ruoyi.hotel.util.DBUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @BelongsProject: ruoyi
 * @BelongsPackage: com.ruoyi.system.service.impl
 * @Author: lbw
 * @CreateTime: 2025-06-20  11:42
 * @Description: TODO
 */
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {

//    @Resource
//    private TestMapper testMapper;

    @Resource
    private RoomMapper roomMapper;

    @Autowired
    private HomeStayMapper homeStayMapper;

    @Override
    public Boolean save(RoomFrom roomFrom) {
        return null;
    }

    @Override
    public Boolean update(RoomFrom homeStayFrom) {
        return null;
    }

    @Override
    public Boolean deleteById(Long id) {
        return null;
    }

    @Override
    public Boolean deleteByIds(List<Long> ids) {
        return null;
    }

    @Override
    public List<RoomVo> selectList(Room query) {
        QueryWrapper<Room> queryWrapper=new QueryWrapper<Room>();
        homeStayMapper.selectById(1);
        List<Room> rooms = roomMapper.selectList(queryWrapper);

        List<RoomVo> roomVos = RoomConverter.converterToVoByPo(rooms);
        return roomVos;
    }

    @Override
    public IPage selectPage(RoomQuery query) {
        QueryWrapper<Room> queryWrapper=new QueryWrapper<>();
        Page<Room> page=new Page<>(query.getPageNum(),query.getPageSize());
        Page<Room> result = roomMapper.selectPage(page, queryWrapper);
        List<RoomVo> roomVos = RoomConverter.converterToVoByPo(result.getRecords());
        return PageConverter.convertToPage(page,roomVos);
    }

    @Override
    public RoomVo selectById(Long id) {
        return null;
    }


    private void autoQuery(RoomQuery query, QueryWrapper<Room> queryWrapper) {
        queryWrapper.lambda()
        ;
        DBUtil.autoQuery(queryWrapper,query,Room.class);
    }
}